Fix duplicate Agentuity keys in .env file creation#459
Conversation
Filter out AGENTUITY_* prefixed environment variables from project.Env and project.Secrets before writing to .env file to prevent duplicates. The dev command was creating duplicate AGENTUITY_SDK_KEY and AGENTUITY_PROJECT_KEY entries when running 'agentuity dev' because: 1. Lines 87-92 wrote ALL env vars including AGENTUITY_* vars from cloud 2. Lines 94-95 then wrote AGENTUITY_SDK_KEY and AGENTUITY_PROJECT_KEY again This fix uses the existing envutil.IsAgentuityEnv regex pattern to filter out Agentuity-prefixed variables, following the same pattern used elsewhere in the codebase (envutil.go lines 111-113, 187-189). Fixes issue reported in Slack where running 'bun run dev' created duplicate/random SDK and project keys in .env file. Co-Authored-By: Rick Blalock <rickblalock@mac.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
WalkthroughThe dev command’s .env generation now skips writing entries that match the Agentuity env pattern from both project.Env and project.Secrets; CHANGELOG.md had a formatting-only edit (removed an empty line). Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant CLI as dev command
participant CFG as Project Config (Env & Secrets)
participant WR as .env Writer
participant FILE as .env File
Dev->>CLI: Run dev
CLI->>CFG: Load Env and Secrets
loop For each key/value in Env and Secrets
CLI->>CLI: Check envutil.IsAgentuityEnv(key)?
alt Matches Agentuity pattern
CLI->>WR: Skip write for this key
else Not a match
WR->>FILE: Write KEY=VALUE
end
end
note over CLI,WR: After iteration
CLI->>WR: Write AGENTUITY_SDK_KEY
CLI->>WR: Write AGENTUITY_PROJECT_KEY
WR->>FILE: Append keys
CLI-->>Dev: Done
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Comment |
Fix duplicate Agentuity keys in .env file creation
Summary
Fixes a bug where running
agentuity devcreates duplicateAGENTUITY_SDK_KEYandAGENTUITY_PROJECT_KEYentries in the.envfile with different values.Root cause: When creating a new
.envfile, the dev command was:project.Envandproject.Secrets(including any existingAGENTUITY_*vars)AGENTUITY_SDK_KEYandAGENTUITY_PROJECT_KEYagainSolution: Filter out
AGENTUITY_*prefixed variables using the existingenvutil.IsAgentuityEnvregex before writing them to.env, preventing duplicates.Review & Testing Checklist for Human
.envfile from a Bun project, runagentuity dev, verify no duplicateAGENTUITY_SDK_KEY/AGENTUITY_PROJECT_KEYentriesenvutil.IsAgentuityEnvmatches all intendedAGENTUITY_*variables and nothing else.envcorrectlyAGENTUITY_SDK_KEYandAGENTUITY_PROJECT_KEYare still written as expectedNotes
envutil.IsAgentuityEnvregex pattern already used elsewhere in the codebase for filtering (seeinternal/envutil/envutil.golines 111-113, 187-189)bun run devcreated random/duplicate SDK keys in.envSummary by CodeRabbit
Bug Fixes
Documentation